package com.ruoyi.wuchuan.service.impl;

import com.ruoyi.wuchuan.domain.EcoNameDTO;
import com.ruoyi.wuchuan.domain.ZszDTO;
import com.ruoyi.wuchuan.mapper.DictDataTypeMapper;
import com.ruoyi.wuchuan.service.DictDataTypeService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.LinkedList;
import java.util.List;

/**
 * 字典指标数据
 */
@Service
public class DictDataTypeServiceImpl implements DictDataTypeService {
    @Resource
    private DictDataTypeMapper dictDataTypeMapper;

    @Override
    public List<EcoNameDTO> getDictData() {
        List<EcoNameDTO> list = null;
        try{
            list  = dictDataTypeMapper.queryDictDataByLevel(2);//先查出2级目录
            if(list !=null && list.size() > 0){
                for ( EcoNameDTO eco: list ) {
                    List<ZszDTO> zszDTOS = dictDataTypeMapper.queryDictDataByPid(eco.getId().toString());//查出3级目录
                    if(zszDTOS !=null && zszDTOS.size()>0 ){
                        eco.setZsz(zszDTOS);
                    }
                }
            }
            return list;
        }catch (Exception e){
            e.printStackTrace();
        }
        return null;
    }
}
